<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type = "checkbox" id = "all">全选/全不选
    <br>
    <input type = "checkbox" class = "life">吃饭
    <br>
    <input type = "checkbox" class = "life">睡觉
    <br>
    <input type = "checkbox" class = "life">玩耍
    <br>
</body>
<script>
    let All = document.querySelector("#all");
    let Life = document.querySelectorAll(".life");
    console.dir(Life);
    All.onclick = function()
    {
        for(let i = 0 ; i<Life.length ; i++)
        {
            Life[i].checked = All.checked;
        }
    }
    for(let i = 0; i<Life.length ;i++)
    {
        Life[i].onclick = function()
        {
            All.checked = CheckLife();
        }
    }
    function CheckLife()
    {
        for(let i = 0; i<Life.length ;i++)
        {
            if(Life[i].checked == false)
            {
                return false;
            }
        }
        return true;
    }
</script>
</html>